package com.interagriculture.controller;

import com.interagriculture.annotation.AdminVerify;
import com.interagriculture.common.Result;
import com.interagriculture.entity.Journalism;
import com.interagriculture.entity.JournalismMain;
import com.interagriculture.entity.dto.JournalismDTO;
import com.interagriculture.service.JournalismMainService;
import com.interagriculture.service.JournalismService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;

/**
 * @author 11 2024/11/14
 */
@RestController
@RequestMapping("/adminJournalism")
public class AdminJournalismController {

    @Resource
    private JournalismService journalismService;
    @Resource
    private JournalismMainService journalismMainService;

    /**
     * 新增或修改新闻
     * @param journalismDTO
     * @return
     */
    @PostMapping("/saveOrUpdate")
    @AdminVerify
    public Result saveOrUpdate(@RequestBody JournalismDTO journalismDTO){
        journalismService.saveOrUpdate(journalismDTO);
        return Result.ok();
    }

    /**
     * 删除新闻
     * @param id
     * @return
     */
    @DeleteMapping("/delete")
    @AdminVerify
    public Result delete(@RequestParam Integer id){
       journalismService.deleteById(id);
        return Result.ok();
    }
}
